<template>
  <div>
    <h1 align="center">管理员登录</h1>
    <table class="table table-bordered">
      <tr>
        <td align="center">名称</td>
        <td>
          <input type="text" v-model="state.user">
        </td>
      </tr>
      <tr>
        <td align="center">密码</td>
        <td>
          <input type="password" v-model="state.pwd">
        </td>
      </tr>
      <tr>
        <td align="center" colspan="2">
          <input type="button" value="登录" @click="ok">
        </td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import {reactive,toRefs,onMounted} from 'vue'
import axios from 'axios'
import {useRouter,useRoute}from 'vue-router'
const router = useRouter();
const route = useRoute();
let data:any=reactive({
  state:{
    user:'',
    pwd:''
  }
})
let {state} = toRefs(data)
const ok =()=>
{
  let obj = {
    user:state.value.user,
    pwd:state.value.pwd
  }
   axios({
    url:'/api/JIuidan/DengLu',
    method:'get',
    params:obj
   })
   .then(res=>{
    console.log(res)
    if (res.data.data==null) {
      alert("账号或密码错误,请联系管理员");
      return;
    }
    else{
      alert("登录成功");
      router.push('/Add')
    }
   })
   .catch(err=>{
    console.log(err)
   })
}
</script>

<style scoped>

</style>